package com.qf.mapper;

import com.qf.entity.Subject;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SubjectMapper {
    @Select("SELECT sub.* FROM `subject` sub " +
            "JOIN stu_sub ss ON sub.sub_id = ss.sub_id " +
            "WHERE ss.sid = #{stuId}")
    List<Subject> findSubjectsByStuId(Integer stuId);
    @Select("SELECT sub.* FROM `subject` sub " +
            "JOIN stu_sub ss ON sub.sub_id = ss.sub_id " +
            "WHERE ss.sid = #{stuId}")
    @Results({
            @Result(column = "sub_id", property = "subId"),
            @Result(column = "sub_name", property = "subName"),
            @Result(column = "sub_id", property = "teacherList",
                    many = @Many(select = "com.qf.mapper.TeacherMapper.findTeachersBySubId"))
    })
    List<Subject> findSubjectsWithTeachersByStuId(Integer stuId);
}
